<?php
/**
 * This is the shortcut to DIRECTORY_SEPARATOR
 */
defined('DS') or define('DS',DIRECTORY_SEPARATOR);

/**
 * This is the shortcut to Yii::app()
 */
function app(){
	return Yii::app();
	}
	
/**
 * This is the shortcut to Yii::app()->clientScript
 */
function cs()
{
    // You could also call the client script instance via Yii::app()->clientScript
    // But this is faster
    return Yii::app()->getClientScript();
}
/**
 * This is the shortcut to CHtml::script();
 */
function j($text){
	return CHtml::script($text);
	}
	
/**
 * This is the shortcut to Yii::app()->request->urlReferrer
 */
 function referrer(){
	 return Yii::app()->request->urlReferrer;
	 }
	
/**
 * This is the shorcut to Yii::app()->request->getQuery();
 */
 function getQuery($name,$default=NULL){
	 return Yii::app()->request->getQuery($name,$default);
	 }

/**
 * This is the shorcut to Yii::app()->request->getPost();
 */
 function getPost($name,$default=NULL){
	 return Yii::app()->request->getPost($name,$default);
	 }
/**
 * This is the shortcut to images path
 */
function image(){
	return Yii::app()->request->baseUrl."/images/";
	}
	
/**
 * This is the shortcut to js path
 */
 function js(){
	 return Yii::app()->request->baseUrl."/javascript/";
	 }
 
/**
 * This is the shortcut to Yii::app()->user.
 */
function user() 
{
    return Yii::app()->getUser();
}
 
/**
 * This is the shortcut to Yii::app()->createUrl()
 */
function url($route,$params=array(),$ampersand='&')
{
    return Yii::app()->createUrl($route,$params,$ampersand);
}
 
/**
 * This is the shortcut to CHtml::encode
 */
function h($text)
{
    return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset);
}
 
/**
 * This is the shortcut to CHtml::link()
 */
function l($text, $url = '#', $htmlOptions = array()) 
{
    return CHtml::link($text, $url, $htmlOptions);
}
 
/**
 * This is the shortcut to Yii::t() with default category = 'stay'
 */
function t($message, $category = 'stay', $params = array(), $source = null, $language = null) 
{
    return Yii::t($category, $message, $params, $source, $language);
}
 
/**
 * This is the shortcut to Yii::app()->request->baseUrl
 * If the parameter is given, it will be returned and prefixed with the app baseUrl.
 */
function bu($url=null) 
{
    static $baseUrl;
    if ($baseUrl===null)
        $baseUrl=Yii::app()->getRequest()->getBaseUrl();
	$baseUrl='http://book.91zili.com';	
    return $url===null ? $baseUrl : $baseUrl.'/'.ltrim($url,'/');
}

/**
 * This is the shortcut to Yii::app()->basePath
 */
function bp(){
	return Yii::app()->basePath;
	}
	
/**
 * import uc client
 */
 function importUc(){
	 include_once(bp().'/vendors/ucenter.php');
	 }

/**
 * This is the shortcut to Yii::app()->user->setFlash();
 */
function sf($key,$value,$defaultvalue=Null){
		return Yii::app()->user->setFlash($key,$value,$defaultvalue);
	}
	
/**
 * This is the shortcut to Yii::app()->user->getFlash();
 */
 function gf($key,$defaultvalue=Null,$delete=True){
		return Yii::app()->user->getFlash($key,$defaultvalue,$delete);
	}
	
/**
 *This is the shorcut to Yii::app()->user->hasFlash();
 */
 function hf($key){
		return Yii::app()->user->hasFlash($key);
	}
/**
 * Returns the named application parameter.
 * This is the shortcut to Yii::app()->params[$name].
 */
function param($name) 
{
    return Yii::app()->params[$name];
}
